/**
 */
package de.thwildau.tm.moses.xabnf.xabnf.impl;

import de.thwildau.tm.moses.abnf.abnf.Rule;

import de.thwildau.tm.moses.xabnf.xabnf.GeneratorModel;
import de.thwildau.tm.moses.xabnf.xabnf.Language;
import de.thwildau.tm.moses.xabnf.xabnf.XabnfPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Generator Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.xabnf.xabnf.impl.GeneratorModelImpl#getFile <em>File</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.xabnf.xabnf.impl.GeneratorModelImpl#getLanguage <em>Language</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.xabnf.xabnf.impl.GeneratorModelImpl#getPackage <em>Package</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.xabnf.xabnf.impl.GeneratorModelImpl#getEntryRule <em>Entry Rule</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.xabnf.xabnf.impl.GeneratorModelImpl#getEncoding <em>Encoding</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GeneratorModelImpl extends MinimalEObjectImpl.Container implements GeneratorModel
{
  /**
   * The default value of the '{@link #getFile() <em>File</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFile()
   * @generated
   * @ordered
   */
  protected static final String FILE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getFile() <em>File</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFile()
   * @generated
   * @ordered
   */
  protected String file = FILE_EDEFAULT;

  /**
   * The default value of the '{@link #getLanguage() <em>Language</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLanguage()
   * @generated
   * @ordered
   */
  protected static final Language LANGUAGE_EDEFAULT = Language.JAVA;

  /**
   * The cached value of the '{@link #getLanguage() <em>Language</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLanguage()
   * @generated
   * @ordered
   */
  protected Language language = LANGUAGE_EDEFAULT;

  /**
   * The default value of the '{@link #getPackage() <em>Package</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPackage()
   * @generated
   * @ordered
   */
  protected static final String PACKAGE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getPackage() <em>Package</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPackage()
   * @generated
   * @ordered
   */
  protected String package_ = PACKAGE_EDEFAULT;

  /**
   * The cached value of the '{@link #getEntryRule() <em>Entry Rule</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEntryRule()
   * @generated
   * @ordered
   */
  protected Rule entryRule;

  /**
   * The default value of the '{@link #getEncoding() <em>Encoding</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEncoding()
   * @generated
   * @ordered
   */
  protected static final String ENCODING_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getEncoding() <em>Encoding</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEncoding()
   * @generated
   * @ordered
   */
  protected String encoding = ENCODING_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected GeneratorModelImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return XabnfPackage.Literals.GENERATOR_MODEL;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getFile()
  {
    return file;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFile(String newFile)
  {
    String oldFile = file;
    file = newFile;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XabnfPackage.GENERATOR_MODEL__FILE, oldFile, file));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Language getLanguage()
  {
    return language;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setLanguage(Language newLanguage)
  {
    Language oldLanguage = language;
    language = newLanguage == null ? LANGUAGE_EDEFAULT : newLanguage;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XabnfPackage.GENERATOR_MODEL__LANGUAGE, oldLanguage, language));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getPackage()
  {
    return package_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPackage(String newPackage)
  {
    String oldPackage = package_;
    package_ = newPackage;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XabnfPackage.GENERATOR_MODEL__PACKAGE, oldPackage, package_));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Rule getEntryRule()
  {
    if (entryRule != null && entryRule.eIsProxy())
    {
      InternalEObject oldEntryRule = (InternalEObject)entryRule;
      entryRule = (Rule)eResolveProxy(oldEntryRule);
      if (entryRule != oldEntryRule)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, XabnfPackage.GENERATOR_MODEL__ENTRY_RULE, oldEntryRule, entryRule));
      }
    }
    return entryRule;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Rule basicGetEntryRule()
  {
    return entryRule;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setEntryRule(Rule newEntryRule)
  {
    Rule oldEntryRule = entryRule;
    entryRule = newEntryRule;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XabnfPackage.GENERATOR_MODEL__ENTRY_RULE, oldEntryRule, entryRule));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getEncoding()
  {
    return encoding;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setEncoding(String newEncoding)
  {
    String oldEncoding = encoding;
    encoding = newEncoding;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XabnfPackage.GENERATOR_MODEL__ENCODING, oldEncoding, encoding));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case XabnfPackage.GENERATOR_MODEL__FILE:
        return getFile();
      case XabnfPackage.GENERATOR_MODEL__LANGUAGE:
        return getLanguage();
      case XabnfPackage.GENERATOR_MODEL__PACKAGE:
        return getPackage();
      case XabnfPackage.GENERATOR_MODEL__ENTRY_RULE:
        if (resolve) return getEntryRule();
        return basicGetEntryRule();
      case XabnfPackage.GENERATOR_MODEL__ENCODING:
        return getEncoding();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case XabnfPackage.GENERATOR_MODEL__FILE:
        setFile((String)newValue);
        return;
      case XabnfPackage.GENERATOR_MODEL__LANGUAGE:
        setLanguage((Language)newValue);
        return;
      case XabnfPackage.GENERATOR_MODEL__PACKAGE:
        setPackage((String)newValue);
        return;
      case XabnfPackage.GENERATOR_MODEL__ENTRY_RULE:
        setEntryRule((Rule)newValue);
        return;
      case XabnfPackage.GENERATOR_MODEL__ENCODING:
        setEncoding((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case XabnfPackage.GENERATOR_MODEL__FILE:
        setFile(FILE_EDEFAULT);
        return;
      case XabnfPackage.GENERATOR_MODEL__LANGUAGE:
        setLanguage(LANGUAGE_EDEFAULT);
        return;
      case XabnfPackage.GENERATOR_MODEL__PACKAGE:
        setPackage(PACKAGE_EDEFAULT);
        return;
      case XabnfPackage.GENERATOR_MODEL__ENTRY_RULE:
        setEntryRule((Rule)null);
        return;
      case XabnfPackage.GENERATOR_MODEL__ENCODING:
        setEncoding(ENCODING_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case XabnfPackage.GENERATOR_MODEL__FILE:
        return FILE_EDEFAULT == null ? file != null : !FILE_EDEFAULT.equals(file);
      case XabnfPackage.GENERATOR_MODEL__LANGUAGE:
        return language != LANGUAGE_EDEFAULT;
      case XabnfPackage.GENERATOR_MODEL__PACKAGE:
        return PACKAGE_EDEFAULT == null ? package_ != null : !PACKAGE_EDEFAULT.equals(package_);
      case XabnfPackage.GENERATOR_MODEL__ENTRY_RULE:
        return entryRule != null;
      case XabnfPackage.GENERATOR_MODEL__ENCODING:
        return ENCODING_EDEFAULT == null ? encoding != null : !ENCODING_EDEFAULT.equals(encoding);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (file: ");
    result.append(file);
    result.append(", language: ");
    result.append(language);
    result.append(", package: ");
    result.append(package_);
    result.append(", encoding: ");
    result.append(encoding);
    result.append(')');
    return result.toString();
  }

} //GeneratorModelImpl
